//
//  ViewController.m
//  DelegateDemo
//
//  Created by shk on 14/12/10.
//  Copyright (c) 2014年 com.shk. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"

@interface ViewController ()
{

    UILabel *_label;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor purpleColor];
    
    _label = [[UILabel alloc] initWithFrame:CGRectMake(120, 100, 140, 40)];
    _label.text = @"hello";
    [self.view addSubview:_label];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.tag = 101;
    button.frame = CGRectMake(100, 140, 140, 40);
    [button setTitle:@"open Next View" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(openNextView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
    
    
    
}

-(void)openNextView{
    SecondViewController *view = [[SecondViewController alloc] init];
    
    view.delegateChange = self;//使当前对象作为代理者（实例化代理属性）
    
    [self presentViewController:view animated:YES completion:^{
        
    }];

}

//实现代理中的函数
-(void)changLabelText:(NSString *)text
{

    _label.text = text;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
